<?php

/**
 * index
 * @author 刘军 
 * @version 1.0
 * @package application
 */
class Team_member extends Front_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->model('team_member_model');
        $this->load->model('news_model');
        $this->load->model('company_model');
//        $this->load->model('member_company_info_model');
    }

    public function index() {
        $this->lists();
    }

    public function lists() {

        // 总数与分页
        $total = $this->team_member_model->total();
        $data['total'] = $total;
        // 请使用config_item( 'per_page' )获取全局显示条数
        $per_page = config_item('per_page');
        $per_page = 16;
        $this->load->library('pagination');
        $pagination_config = array(
            'base_url' => base_url($this->_site_path . '/team_member/index'),
            'total_rows' => $total,
            'per_page' => $per_page,
            'uri_segment' => 4,
        );
        $pagination_config = array_merge($pagination_config, $this->pagination_config);
        //分页
        $this->pagination->initialize($pagination_config);
        $data['pagination'] = $this->pagination->create_links();
        $search['limit'] = array('persize' => $per_page, 'offset' => $this->pagination->get_cur_offset());
        $fields = array('id', 'name', 'photo_url');
        $data['teamMember'] = $this->team_member_model->get_appoint_values($fields, null, $search);

        $this->load->view($this->_site_path . '/team_member/index', $data);
    }

    public function single($id = 0) {
        $data['info'] = $this->team_member_model->get_by_pk($id);
        if (!$data['info']) {
            header('location:' . base_url($this->_site_path . '/index/index'));
            exit;
        }
        $data['pre'] = $this->team_member_model->pre($id);
        $data['next'] = $this->team_member_model->next($id);

        //pe($data);
        //增加文章的点击次数
        $this->load->view($this->_site_path . '/team_member/single', $data);
    }

}
